<?php

namespace mpend\modules\h5\models\traits;

use common\models\user\UserAccountOrange;

trait User {

    public function getUser() {
        $user = \mpend\modules\h5\models\User::findOne($this->_token->user_id);
        return $user;
    }

    public function getOrange() {
        $user = \mpend\modules\h5\models\User::findOne($this->_token->user_id);
        $orange = $user->orange;
        if (!$orange) {
            $orange = new UserAccountOrange();
        }
        return [
            'id' => $orange->id,
            'current' => $orange->current,
            'amount' => $orange->amount,
            'status' => $orange->status,
        ];
    }

}
